package demo.state;

import demo.People;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ZhouWeiBo
 * @create 2022/6/6
 */
public class StateHandler {
    private Map<Integer, demo.state.PeopleState> stateMap = new ConcurrentHashMap<>();

    public StateHandler() {
        stateMap.put(0,new demo.state.Happy());
        stateMap.put(1,new demo.state.Bored());
        stateMap.put(2,new demo.state.Sad());
    }

    public void doState(People people){
        demo.state.PeopleState state = stateMap.get(people.getState());
        state.doSomething(people.getName());
    }
}
